package com.flower.oss.controller;

import com.alibaba.nacos.api.config.annotation.NacosValue;
import com.flower.oss.service.FileService;
import io.minio.errors.*;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.beans.factory.annotation.Value;

import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * @author lavender
 * @version 1.0
 * @date 2024-07-11 18:27
 */
@RestController
@RefreshScope
@RequestMapping("/test")
public class FileController {

    @Resource
    private FileService fileService;

    @Value(value = "${storage.service.type}")
    private String storageType;

    @Value("${useLocalCache:false}")
    private boolean useLocalCache;


    @RequestMapping("/fill")
    public String test() throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {

        List<String> allBuckets = fileService.getAllBucket();

        return allBuckets.get(0);
    }

    @RequestMapping("/")
    public String test2(){
        return storageType;
    }
}
